<template>
	<view class="address_choose_box Column">
		<!-- 渲染收货信息的盒子 -->
		<view class="addressInfoBox Column">
			<view v-if="teamUserLists.length">
				<view class="rowChild Column" v-for="(item,index) in teamUserLists" :key="index" :data-id="item.id">
					<view class="fristBox flex-row items-center justifyCont-bet">
						<view class="flex-row items-center">
							<view class="iconfont avatar">&#xe67c;</view>
							<view class="username">{{item.user.nickname}}</view>
						</view>

						<view class="username" :style="item.inviter_hierarchy == 1 ?  'color:#f78700;'
							: 'color:#007aff;' ">{{item.inviter_hierarchy == 1 ?  "直推" : "团队"}}</view>
					</view>

					<view class="flex-row items-center justifyCont-bet" style="padding-bottom: 4px;">
						<view class="mobileText">电话</view>
						<view class="mobile">{{item.user.mobile}}</view>
					</view>

					<view class="flex-row items-center justifyCont-bet" style="font-size: 14px;">
						<view class="mobileText">会员等级</view>
						<view class="mobile">{{item.user.group.name}}</view>
					</view>
				</view>
			</view>

			<view class="content" v-else>暂无数据</view>
		</view>
	</view>
</template>

<script>
	import {
		postMenu,
		getMenu
	} from '@/utils/api.js';
	import {
		apiTeamUsers
	} from '@/api/home.js';

	export default {
		data() {
			return {
				teamUserLists: [],
				current_page: 1,
				last_page: 1,
			};
		},
		onShow() {
			this.pageRefresh();
		},
		methods: {
			pageRefresh() {
				this.teamUserLists = [];
				this.current_page = 1;
				this.last_page = 1;
				this.getTeamUsers();
			},

			getTeamUsers() {
				apiTeamUsers({
						params: {
							// uid: 14,
							page: this.current_page
						}
					})
					.then(res => {
						const array = res.data.data;
						array.forEach(element => {
							this.teamUserLists.push(element)
						})

						this.last_page = res.data.last_page;
					}).catch(err => console.log(err))
			},
		},
		onReachBottom() {
			let that = this;
			that.current_page++;
			if (that.current_page > that.last_page) {
				uni.$u.toast("暂无更多~");
				return;
			}
			that.getTeamUsers()
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #F5F6F8;
	}

	.address_choose_box {
		padding: 24rpx;

		// 渲染收货信息的盒子
		.addressInfoBox {
			justify-content: center;

			.content {
				display: flex;
				justify-content: center;
				align-items: center;
				height: 90vh;
			}

			.rowChild:last-child {
				margin-bottom: 0;
			}

			// 第一行
			.rowChild {
				justify-content: space-between;
				background-color: #fff;
				border-radius: 20rpx;
				padding: 24rpx;
				margin-bottom: 16rpx;

				.fristBox {
					border-bottom: 1px solid #e2e2e2;
					padding: 0 0 10px;
					margin-bottom: 8px;
				}

				.avatar {
					font-size: 22px;
					margin-right: 8px;
				}

				.username,
				.mobileText {
					font-size: 16px;
				}

				.mobile {
					color: #888888;
					font-size: 16px;
				}
			}
		}
	}
</style>